****************************************************************************************
****************************************************************************************
** TABLE 3
****************************************************************************************
****************************************************************************************

use "${path}data_table.dta", clear


label var nb_collab_same_labex "\emph{Links}"
label var citations_new "\emph{Cites}"
gen age_2010 = age if year ==2010
bys id_20:  egen age_in_2010=max( age_2010)
drop age_2010
gen discipline=0
replace discipline=1 if biologie_fondamentale ==1
replace discipline=2 if recherche_medicale ==1
replace discipline=3 if biologie_appliquee_ecologie ==1
replace discipline=4 if chimie ==1
replace discipline=5 if physique ==1
replace discipline=6 if sciences_univers ==1
replace discipline=7 if sciences_ingenieur ==1
replace discipline=8 if mathematiques ==1
replace discipline=9 if SS ==1
replace discipline=10 if SH ==1
global contr biblio age biologie_fondamentale recherche_medicale biologie_appliquee_ecologie chimie physique sciences_univers sciences_ingenieur mathematiques SS SH
local regnom    "orga_main_rev3"
eststo clear 
qui eststo:  reghdfe nb_collab_same_labex treat2  if  id_year==1  & criterion_grade==1  ,  a( i.discipline#i.year age_in_2010#i.year female_new#i.year  year id_2019) cluster(labexid)  
qui :  estadd ysumm  
qui :  estadd scalar clusters = e(N_clust)
qui eststo:  reghdfe nb_collab_same_labex treat2  if  id_year==1  & criterion_grade==1 ,  a( year i.discipline#i.year age_in_2010#i.year female_new#i.year  year_labex##note_3##discipline ) cluster(labexid)  
qui :  estadd ysumm 
qui :  estadd scalar clusters = e(N_clust)
qui eststo:  reghdfe nb_collab_same_labex treat2  if  id_year==1  & criterion_grade==1 & distance>10 , a( i.discipline#i.year age_in_2010#i.year female_new#i.year  year id_2019) cluster(labexid)
qui :  estadd ysumm  
qui :  estadd scalar clusters = e(N_clust)
qui eststo:  reghdfe nb_collab_same_labex treat2  if  id_year==1  & criterion_grade_propbib==1 & prop_biblabex_labo!=0 ,  a( i.discipline#i.year age_in_2010#i.year female_new#i.year  year id_2019) cluster(labexid)     
qui :  estadd ysumm   
qui :  estadd scalar clusters = e(N_clust)
esttab,  compress ar2 starlevels(* 0.1 ** 0.05 *** 0.01)  b(%4.3f) se(%4.3f) label   keep(treat2) stats(N clusters ymean r2_a , fmt(%9.0g %9.0g %9.2g %9.2g  ) labels("Observations" "Number of Clusters" "Mean dep variable" "Adj. R-Square" )) nolegend nose nonotes 
esttab using  `regnom',   b(%4.3f) se(%4.3f) ar2 starlevels({$^{*}$} 0.1 {$^{**}$} 0.05 {$^{***}$} 0.01)  tex  label replace keep(treat2) stats(N clusters ymean r2_a, fmt(%9.0g %9.2g %9.2g  ) labels("Observations" "Number of Clusters" "Mean dep variable" "Adj. R-Square" )) nolegend nonotes
eststo clear 
local regnom    "prod_main_rev3"
eststo clear 
